﻿//创建时间: 2011-06-22
//创建作者: 李 城
//功能说明: 安装时用户的信息记录
//最后修改: 2011-06-22
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using TRPOP.CMS.Business;
using TRPOP.CMS.Model;
using System.Web;

using TRPOP.Config;
using TRPOP.Common;
/*
 *  专门针对 http://admin.yorknet.cn/cms 上的内容模型--用户（企业）信息模型  ModelId:5
 *  
 *  
*/
namespace TRPOP.CMS.Web.ExtraBus
{
    /// <summary>
    /// 注册用户的信息统计
    /// </summary>
    public class Page_Load_EnterpRecord : BasePage
    {
        protected override void OnInit(EventArgs e)
        {
            SaveUserInfo();
        }
        /// <summary>
        /// 保存用户基本信息
        /// </summary>
        public void SaveUserInfo()
        {
            Response.Clear();
            Response.ClearHeaders();
            Response.ClearContent();
            //接收页面传输的字符串
            string strEnterpName = RequestHelper.RequestString("EnterpriseName");//必填
            string strLinkMan = RequestHelper.RequestString("LinkMan");//必填
            string strlinkTel = RequestHelper.RequestString("linkTel");//必填
            string strLinkAddress = RequestHelper.RequestString("LinkAddress");//不是必填
            string strWebSite = RequestHelper.RequestString("WebSite");//不是必填
            string strEmail = RequestHelper.RequestString("Email");//不是必填
            string strQQ = RequestHelper.RequestString("QQ");//不是必填
            string strMSN = RequestHelper.RequestString("MSN");//不是必填
            //判断信息是否为空
            if (strEnterpName.IsEmpty() ||
                strLinkMan.IsEmpty() ||
                strlinkTel.IsEmpty()
                )
                return;
            //添加信息
            List<ModelFieldInfoWithTableName> m_ModelFieldInfoListSource = new ModelFieldManage().GetWithTableNameListByModelId(5);
            if(m_ModelFieldInfoListSource==null || m_ModelFieldInfoListSource.Count<=0)
                return;
            List<ModelFieldInfoWithTableName> m_ModelFieldInfoList = new List<ModelFieldInfoWithTableName>();
            foreach (ModelFieldInfoWithTableName FieldInfo in m_ModelFieldInfoListSource)
            {
                m_ModelFieldInfoList.Add(FieldInfo.Clone() as ModelFieldInfoWithTableName);
            }
            foreach (ModelFieldInfoWithTableName FieldInfo in m_ModelFieldInfoList)
            {
                switch (FieldInfo.FieldName.ToLower().Trim())
                {
                    case "enterprisename":
                        FieldInfo.DefaultValue = strEnterpName;
                        break;
                    case "linkman":
                        FieldInfo.DefaultValue = strLinkMan;
                        break;
                    case "linktel":
                        FieldInfo.DefaultValue = strlinkTel;
                        break;
                    case "linkaddress":
                        FieldInfo.DefaultValue = strLinkAddress;
                        break;
                    case "website":
                        FieldInfo.DefaultValue = strWebSite;
                        break;
                    case "email":
                        FieldInfo.DefaultValue = strEmail;
                        break;
                    case "qq":
                        FieldInfo.DefaultValue = strQQ;
                        break;
                    case "msn":
                        FieldInfo.DefaultValue = strMSN;
                        break;
                    case "ipadress":
                        FieldInfo.DefaultValue = RequestHelper.GetIP();
                        break;
                    case "macadress":
                        try
                        {
                            FieldInfo.DefaultValue = RequestHelper.GetMac(RequestHelper.GetIP());
                        }
                        catch { }
                        break;
                    case "urlreferrer":
                        FieldInfo.DefaultValue = RequestHelper.GetUrlReferrer();
                        break;
                    default:
                        break;
                }
            }
            ContentInfo oContentInfo = new ContentInfo();
            oContentInfo.Name = strEnterpName;
            oContentInfo.NodeId = 37;
            oContentInfo.AddTime = DateTime.Now;
            oContentInfo.UpdateTime = DateTime.Now;
            oContentInfo.PubTime = DateTime.Now;
            if (new ContentManage().SaveNewDoc(oContentInfo, m_ModelFieldInfoList) == EnumSubmitResult.Success)
                Response.Write("OK");
            else
                Response.Write("Error");
        }
    }
}
